<?php
	define('DB_USER', "david");//Default database user name
	define('DB_PW', "123456");//Default database password
	define('DB', "WC");//Default query schema
	define("CONN_STRING","mysql:host=127.0.0.1;dbname:");//PDO connection string , connect to local host mysql 
	function create_connection($db=DB)
	{
        /**
        * params    description
        * $db       DB Schema to connect , default is defined above .  
        * Return PDO connection object 
        */
		$conn = new PDO(CONN_STRING.$db,DB_USER,DB_PW); // Create connection object
		$conn->setAttribute(pdo::ATTR_ERRMODE,pdo:: ERRMODE_EXCEPTION);//Explicit error mode , If sql error it will throw exceptions  
		$conn->exec("USE ".$db.";");//Define which schema will use
		$conn->exec("SET GLOBAL log_output = 'TABLE';");//Logging output to db.
		$conn->exec("SET GLOBAL general_log = 'ON';"); // Logging query sql 
        $conn->exec("SET NAMES 'UTF8' ");//For handle Chinese, it is necessary to set this. 
		return $conn;//Return connection.
	}
?>